package com.yonyou.pmclouds.plan.processor;

import com.yonyou.pmclouds.basecom.bp.processor.SingleProcessor;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.basecom.exception.IllegalRequestArgException;
import com.yonyou.pmclouds.basecom.util.DateUtils;
import com.yonyou.pmclouds.plan.entity.ProjectPlanVO;

public class PlanDateAdjustAndCheck implements SingleProcessor<ProjectPlanVO> {
    @Override
    public void process(ProjectPlanVO vo, ProjectPlanVO orig) throws BusinessException {
        vo.setExpeStartDate(DateUtils.asDateBegin(vo.getExpeStartDate()));
        vo.setExpeEndDate(DateUtils.asDateEnd(vo.getExpeEndDate()));
        int day = (int) DateUtils.getDaysBetween(vo.getExpeStartDate(), vo.getExpeEndDate());
        if (day != vo.getExpeDuration()) {
            throw new IllegalRequestArgException();
        }
    }
}
